#!coding:utf-8    相信这句大家都懂的，不解释
#导入需要的python模块httplib，用来模拟提交http请求，详细的用法可见python帮助手册
import httplib
#导入需要的python模块urllib，用来对数据进行编码
import urllib
#定义请求头
class connetion:
        reqheaders={
        'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
        'Accept-Encoding':'gzip, deflate',
        'Accept-Language':'zh-CN,zh;q=0.8',
        'Cache-Control':'max-age=0',
        'Connection':'keep-alive',
        'Content-Length':'46',
        'Content-Type':'application/x-www-form-urlencoded',
        'Host':'210.31.224.243',
        'Origin':'http://210.31.224.243',
        'Referer':'http://210.31.224.243/',
        'Upgrade-Insecure-Requests':'1',
        'User-Agent':'Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36',}
        #headers属性
        reqdata={
        'DDDDD':'2015301A820',  #校园网账号
        'upass':'*******',      #校园网密码
        '0MKKey':'',
        }
        #data属性
        
        def connect_url():
            data =urllib.urlencode(reqdata)
            conn=httplib.HTTPConnection('210.31.224.243')
            conn.request('POST', '210.31.224.243',data, reqheaders)
            return;
        def connect_respon():  
            res=conn.getresponse()
            print(data)
            print(res.status)
            print(res.msg)
            return;



